Hi community:
I would like to get the position of the image node "_Assembly1-1" via a script.
I have tried with this code, but it does not work when the node is inside a tree:
For the code:
/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
AUTHOR Rafa
VERSION 0.0.0
Write description of the script here, and put your code after these lines.
import os, re, shutil, math
def GetSelectedNode():
SelectedTree = lux.getSceneTree()
NodeAlreadySelected = False
types = (lux.NODE_TYPE_GROUP, lux.NODE_TYPE_OBJECT, lux.NODE_TYPE_ANIMATION, lux.NODE_TYPE_MODEL_SET, lux.NODE_TYPE_MODEL)
for IsTheSelectedNode in SelectedTree.find(name = "", types = types, depth = 1000):
if IsTheSelectedNode != SelectedTree:
if IsTheSelectedNode.isSelected() & (not NodeAlreadySelected):
GetSelectedNode = IsTheSelectedNode
NodeAlreadySelected = True
break
if not NodeAlreadySelected:
exit()
return GetSelectedNode
def GetTransformationMatrix(MatrixDeTransformacionInWorldSpace):
TransformationMatrix_Vectors = MatrixDeTransformacionInWorldSpace.getTransformation()
TransformationMatrix_Vectors_Scale = TransformationMatrix_Vectors[0]
TransformationMatrix_Vectors_Rotation = TransformationMatrix_Vectors[1]
TransformationMatrix_Vectors_Rotation_DegreesX = math.degrees(TransformationMatrix_Vectors_Rotation.val()[0])
TransformationMatrix_Vectors_Rotation_DegreesY = math.degrees(TransformationMatrix_Vectors_Rotation.val()[1])
TransformationMatrix_Vectors_Rotation_DegreesZ = math.degrees(TransformationMatrix_Vectors_Rotation.val()[2])
TransformationMatrix_Vectors_Translation = TransformationMatrix_Vectors[2]
print("Scale: "+str(TransformationMatrix_Vectors_Scale.val()))
print("")
print("RotationDegreesX: "+str(TransformationMatrix_Vectors_Rotation_DegreesX))
print("RotationDegreesY: "+str(TransformationMatrix_Vectors_Rotation_DegreesY))
print("RotationDegreesZ: "+str(TransformationMatrix_Vectors_Rotation_DegreesZ))
print("")
print("Translation: "+str(TransformationMatrix_Vectors_Translation.val()))
def main():
SelectedNode = GetSelectedNode()
TransformationMatrix = SelectedNode.getTransform(world = True)
GetTransformationMatrix(TransformationMatrix)
main()
/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/
The output is:
Scale: (115.17648682504714, 136.1506659623152, 157.35782650841944)
RotationDegreesX: 21.194303453776122
RotationDegreesY: 21.138110103009087
RotationDegreesZ: 24.730497434905253
Translation: (71.83354208050602, 90.13889263596329, 110.34125451677617)
which does not correspond with the image data.